package game.metalmax.ui.common
{
	import flash.events.Event;
	
	import showtime.framework.component.loading.GroupLoaderEvent;
	import showtime.framework.component.loading.ProgressSprite;

	public class Preloader001 extends ProgressSprite
	{
		private var loader:MC_GAME_LOADER = null;
		
		public function Preloader001()
		{
		}
		
		override protected function addedToStageHandler(evt:Event):void
		{
			super.addedToStageHandler(evt);

			loader = new MC_GAME_LOADER();
			loader.x = width * 0.5;
			loader.y = height * 0.5;
			loader.mouseChildren = false;
			loader.mouseEnabled = false;
			
			addChild(loader);
		
		}

		override public function progress(evt:GroupLoaderEvent):void
		{
			if (evt.bytesTotal != 0)
			{
				loader.valueBar.scaleX = evt.bytesLoaded / evt.bytesTotal;
				loader.informationTxt.text = int(evt.bytesLoaded / evt.bytesTotal) * 100 + "% (" + evt.fileLoaded + " / " + evt.fileTotal + ")";
			}		
		
		}
	}
}